<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@ page  import="java.awt.image.*" %>
<%@ page  import="java.awt.*" %>
<%@ page  import="javax.imageio.*" %>

<%

    Random  rd =new Random();

    BufferedImage  img  =new BufferedImage(60,20,BufferedImage.TYPE_INT_RGB);
    
    Graphics  g = img.getGraphics();
    
    g.setColor(Color.orange);
    g.fillRect(0,0,60,20);
  
  
    g.setColor(Color.gray);
    for(int i=0;i<12;i++){
       g.drawLine(rd.nextInt(60),rd.nextInt(20),rd.nextInt(60),rd.nextInt(20));
    }
  
    String constantStr = "ABCDEFGHIJKLMNOPQARSTUVWXYZabcdefgeeee1234567890"; 
    String seed = "";
    
    for(int i=0;i<4;i++){
      seed+=  constantStr.charAt(rd.nextInt(constantStr.length()));
    }
    
    session.setAttribute("codeInSession",seed);
    
    g.setColor(Color.red);
    g.setFont(new Font("黑体",Font.BOLD,20));
    g.drawString(seed,10,15);
    
 
    ImageIO.write(img,"JPEG",response.getOutputStream());

    out.clear();
    out=pageContext.pushBody();
%>


